package com.example.concurrent.chapter04;

import java.util.HashMap;

/**
 * @author Create By Liuqz
 * @date 2018/11/21 14:27
 *
 * 执行该类, 请确保已保存手头上的工作,该代码有可能导致你的电脑死机
 */
public class HashMapDeadLock {

    private final HashMap<String,String> map = new HashMap<>();

    public void add(String key, String value) {
        this.map.put(key, value);
    }

    public static void main(String[] args) {
        final HashMapDeadLock hmd1 = new HashMapDeadLock();
        for (int i = 0; i < 2; i++) {
            new Thread(() -> {
                for (int j = 0; j < Integer.MAX_VALUE; j++) {
                    hmd1.add(String.valueOf(j),String.valueOf(j));
                }
            }).start();
        }
    }
}
